<?php
namespace app\admin\controller;
use think\Controller;
use think\Request;

/**
 * 后台图片上传
 */
class Image extends Base
{
	public function upload(){

		$file = Request::instance()->file('file');
		//把图片上传到指定文件夹
		$info = $file->move('upload');//在public目录下创建upload目录保存图片
		if ($info && $info->getPathname()) {
			$data = [
				'status'=>1,
				'message'=>'ok',
				'data'=>'/'.$info->getPathname()
			];
			return json_encode($data);
		}

		return json_encode(['status'=>0,'message'=>'上传失败']);
	}
}
